package com.kuaidi100.sdk.request;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * @Author: api.kuaidi100.com
 * @Date: 2020-07-14 15:58
 */
public class QueryTrackParam {
    /**
     * 查询的快递公司的编码，一律用小写字母
     */
    private String com;
    /**
     * 查询的快递单号， 单号的最大长度是32个字符
     */
    private String num;
    /**
     * 收件人或寄件人的手机号或固话
     */
    private String phone;
    /**
     * 出发地城市，省-市-区
     */
    private String from;
    /**
     * 目的地城市，省-市-区
     */
    private String to;
    /**
     * 添加此字段表示开通行政区域解析功能。0：关闭（默认），1：开通行政区域解析功能，2：开通行政解析功能并且返回出发、目的及当前城市信息
     * 1：开通行政区域解析功能以及物流轨迹增加物流状态名称； 4: 开通行政解析功能以及物流轨迹增加物流高级状态名称、状态值并且返回出发、目的及当前城市信息； 8：在4的基础上额外返回预计到达时间和预计轨迹信息
     */
    private String resultv2 = "0";
    /**
     * 返回数据格式。0：json（默认），1：xml，2：html，3：text
     */
    private String show = "0";
    /**
     * 返回结果排序方式。desc：降序（默认），asc：升序
     */
    private String order = "desc";

    @Override
    public String toString() {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.writeValueAsString(this);
        } catch (Exception e) {
            return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                    .append("com", com)
                    .append("num", num)
                    .append("phone", phone)
                    .append("from", from)
                    .append("to", to)
                    .append("resultv2", resultv2)
                    .append("show", show)
                    .append("order", order)
                    .toString();
        }
    }

    public String getCom() {
        return com;
    }

    public void setCom(String com) {
        this.com = com;
    }

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public String getResultv2() {
        return resultv2;
    }

    public void setResultv2(String resultv2) {
        this.resultv2 = resultv2;
    }

    public String getShow() {
        return show;
    }

    public void setShow(String show) {
        this.show = show;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public static QueryTrackParamBuilder toBuilder() {
        return new QueryTrackParamBuilder();
    }

    public static final class QueryTrackParamBuilder {
        private String com;
        private String num;
        private String phone;
        private String from;
        private String to;
        private String resultv2;
        private String show;
        private String order;

        private QueryTrackParamBuilder() {
        }

        public static QueryTrackParamBuilder aQueryTrackParam() {
            return new QueryTrackParamBuilder();
        }

        public QueryTrackParamBuilder com(String com) {
            this.com = com;
            return this;
        }

        public QueryTrackParamBuilder num(String num) {
            this.num = num;
            return this;
        }

        public QueryTrackParamBuilder phone(String phone) {
            this.phone = phone;
            return this;
        }

        public QueryTrackParamBuilder from(String from) {
            this.from = from;
            return this;
        }

        public QueryTrackParamBuilder to(String to) {
            this.to = to;
            return this;
        }

        public QueryTrackParamBuilder resultv2(String resultv2) {
            this.resultv2 = resultv2;
            return this;
        }

        public QueryTrackParamBuilder show(String show) {
            this.show = show;
            return this;
        }

        public QueryTrackParamBuilder order(String order) {
            this.order = order;
            return this;
        }

        public QueryTrackParam build() {
            QueryTrackParam queryTrackParam = new QueryTrackParam();
            queryTrackParam.setCom(com);
            queryTrackParam.setNum(num);
            queryTrackParam.setPhone(phone);
            queryTrackParam.setFrom(from);
            queryTrackParam.setTo(to);
            queryTrackParam.setResultv2(resultv2);
            queryTrackParam.setShow(show);
            queryTrackParam.setOrder(order);
            return queryTrackParam;
        }
    }
}
